	

var app = angular.module("myapp",[]);

app.controller('appCtrl', ['$scope','$http','$location',function($scope,$http){
    $scope.aname = "";
    $scope.modules = [];
    $scope.apps = [];

     $scope.addMod = function(){
        $scope.modules.push($scope.module);
         $scope.module = "";

        }
     $scope.removeMod = function(index){
         $scope.modules.splice(index,1);

     }
    $scope.addApp = function(){
        $scope.apps.push({app:$scope.aname, mod:$scope.modules});

        $http({method:"POST", url:"/users/babu/putApp",data:$scope.apps[0]}).then(function(result){
            $scope.apps = [];
            console.log("done");
         });
    }
}]);

/*app.service('nameService',['$http',function($http){

    var getData = function() {
        return $http({method:"GET", url:"/users/babu/getAllNames"}).then(function(result){
            return result.data;
        });
    };

    return {getData: getData};

}]);

app.service('appService',['$http',function($http){

    var getData = function() {
        return $http({method:"GET", url:"/users/babu/getAllApps"}).then(function(result){
            return result.data;
        });
    };

    return {getData: getData};

}]);

app.controller('my-controller', ['$scope','$http','$location','nameService' ,function($scope,$http,nameService){

    console.log("Client");
    $scope.name = "Suresh";
    $scope.school = "SMRV";
    $scope.age = 28;
    $scope.record = [];

    $scope.postData = function() {
        $scope.record = {name:$scope.name, school:$scope.school, age:$scope.age};

        console.log("Client2");

        $http({method:"POST", url:"/users/babu/putName",data:$scope.record}).then(function(result){
            console.log("done");
            $scope.names.push($scope.name);
        });

    };

 }]); */





 




 


